package indi.zn.commons.loader;

import java.io.File;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;

/**
 * @ProjectName:91isoft_oa
 * @Description: 
 * @author: 周楠
 * @date 2016年3月20日 上午2:11:27
 */

public class ClassPaths {
	
	
	public static String defaultClassPath(){
		
		String utilpath=  ClassPaths.class.getResource("").getPath();
		
		String path=  utilpath.substring(0, utilpath.length()-22);
		
		return path;
	}
	
	public static URL getURIFromClassPath(String path){
		
		return ClassPaths.class.getResource(path);

	}
	
    public static InputStream getInputStreamFromClassPath(String path){
		
		return ClassPaths.class.getResourceAsStream(path);
		
	}
    
    public static File getFileFromClassPath(String path) throws URISyntaxException{
    
    	return new File(ClassPaths.class.getResource(path).toURI());
    }
    
    public static  String getStringPathFromClassPath(String path){
    	
    	return ClassPaths.class.getResource(path).getPath();
    	
    }

    
    public static void main(String[] args) {
		
      System.out.println(ClassPaths.defaultClassPath());	
    	
	}
}
